winsafe\mf\com_interfaces/
imfvideodisplaycontrol.rs

1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::co;
4use crate::decl::*;
5use crate::kernel::privs::*;
6use crate::mf::vts::*;
7use crate::ole::privs::*;
8use crate::prelude::*;
9
10com_interface! { IMFVideoDisplayControl: "a490b1e4-ab84-4d31-a1b2-181e03b1077a";
11	/// [`IMFVideoDisplayControl`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nn-evr-imfvideodisplaycontrol)
12	/// COM interface.
13	///
14	/// Automatically calls
15	/// [`IUnknown::Release`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-release)
16	/// when the object goes out of scope.
17	///
18	/// # Examples
19	///
20	/// ```no_run
21	/// use winsafe::{self as w, prelude::*, co};
22	///
23	/// let get_svc: w::IMFGetService; // initialized somewhere
24	/// # let get_svc = unsafe { w::IMFGetService::null() };
25	///
26	/// let controller_evr = get_svc
27	///     .GetService::<w::IMFVideoDisplayControl>(
28	///         &co::MF_SERVICE::MR_VIDEO_RENDER_SERVICE,
29	///     )?;
30	/// # w::HrResult::Ok(())
31	/// ```
32}
33
34impl mf_IMFVideoDisplayControl for IMFVideoDisplayControl {}
35
36/// This trait is enabled with the `mf` feature, and provides methods for
37/// [`IMFVideoDisplayControl`](crate::IMFVideoDisplayControl).
38///
39/// Prefer importing this trait through the prelude:
40///
41/// ```no_run
42/// use winsafe::prelude::*;
43/// ```
44pub trait mf_IMFVideoDisplayControl: ole_IUnknown {
45	/// [`IMFVideoDisplayControl::GetAspectRatioMode`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-getaspectratiomode)
46	/// method.
47	#[must_use]
48	fn GetAspectRatioMode(&self) -> HrResult<co::MFVideoARMode> {
49		let mut mode = co::MFVideoARMode::default();
50		ok_to_hrresult(unsafe {
51			(vt::<IMFVideoDisplayControlVT>(self).GetAspectRatioMode)(self.ptr(), mode.as_mut())
52		})
53		.map(|_| mode)
54	}
55
56	/// [`IMFVideoDisplayControl::GetBorderColor`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-getbordercolor)
57	/// method;
58	#[must_use]
59	fn GetBorderColor(&self) -> HrResult<COLORREF> {
60		let mut color = COLORREF::default();
61		ok_to_hrresult(unsafe {
62			(vt::<IMFVideoDisplayControlVT>(self).GetBorderColor)(self.ptr(), color.as_mut())
63		})
64		.map(|_| color)
65	}
66
67	/// [`IMFVideoDisplayControl::GetFullscreen`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-getfullscreen)
68	/// method.
69	#[must_use]
70	fn GetFullscreen(&self) -> HrResult<bool> {
71		let mut fulls = 0;
72		ok_to_hrresult(unsafe {
73			(vt::<IMFVideoDisplayControlVT>(self).GetFullscreen)(self.ptr(), &mut fulls)
74		})
75		.map(|_| fulls != 0)
76	}
77
78	/// [`IMFVideoDisplayControl::GetIdealVideoSize`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-getidealvideosize)
79	/// method.
80	///
81	/// Returns minimum and maximum ideal sizes.
82	#[must_use]
83	fn GetIdealVideoSize(&self) -> HrResult<(SIZE, SIZE)> {
84		let (mut min, mut max) = (SIZE::default(), SIZE::default());
85		ok_to_hrresult(unsafe {
86			(vt::<IMFVideoDisplayControlVT>(self).GetIdealVideoSize)(
87				self.ptr(),
88				pvoid(&mut min),
89				pvoid(&mut max),
90			)
91		})
92		.map(|_| (min, max))
93	}
94
95	/// [`IMFVideoDisplayControl::GetNativeVideoSize`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-getnativevideosize)
96	/// method.
97	///
98	/// Returns native and aspect ratio sizes.
99	#[must_use]
100	fn GetNativeVideoSize(&self) -> HrResult<(SIZE, SIZE)> {
101		let (mut native, mut aspec) = (SIZE::default(), SIZE::default());
102		ok_to_hrresult(unsafe {
103			(vt::<IMFVideoDisplayControlVT>(self).GetNativeVideoSize)(
104				self.ptr(),
105				pvoid(&mut native),
106				pvoid(&mut aspec),
107			)
108		})
109		.map(|_| (native, aspec))
110	}
111
112	/// [`IMFVideoDisplayControl::GetVideoPosition`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-getvideoposition)
113	/// method.
114	#[must_use]
115	fn GetVideoPosition(&self) -> HrResult<(MFVideoNormalizedRect, RECT)> {
116		let mut norm_rc = MFVideoNormalizedRect::default();
117		let mut rc = RECT::default();
118
119		ok_to_hrresult(unsafe {
120			(vt::<IMFVideoDisplayControlVT>(self).GetVideoPosition)(
121				self.ptr(),
122				pvoid(&mut norm_rc),
123				pvoid(&mut rc),
124			)
125		})
126		.map(|_| (norm_rc, rc))
127	}
128
129	/// [`IMFVideoDisplayControl::GetVideoWindow`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-getvideowindow)
130	/// method.
131	#[must_use]
132	fn GetVideoWindow(&self) -> HrResult<HWND> {
133		let mut hwnd = HWND::NULL;
134		ok_to_hrresult(unsafe {
135			(vt::<IMFVideoDisplayControlVT>(self).GetVideoWindow)(self.ptr(), hwnd.as_mut())
136		})
137		.map(|_| hwnd)
138	}
139
140	/// [`IMFVideoDisplayControl::RepaintVideo`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-repaintvideo)
141	/// method.
142	fn RepaintVideo(&self) -> HrResult<()> {
143		match unsafe {
144			co::HRESULT::from_raw((vt::<IMFVideoDisplayControlVT>(self).RepaintVideo)(self.ptr()))
145		} {
146			co::HRESULT::S_OK | co::HRESULT::MF_E_INVALIDREQUEST => Ok(()),
147			hr => Err(hr),
148		}
149	}
150
151	/// [`IMFVideoDisplayControl::SetAspectRatioMode`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-setaspectratiomode)
152	/// method.
153	fn SetAspectRatioMode(&self, mode: co::MFVideoARMode) -> HrResult<()> {
154		ok_to_hrresult(unsafe {
155			(vt::<IMFVideoDisplayControlVT>(self).SetAspectRatioMode)(self.ptr(), mode.raw())
156		})
157	}
158
159	/// [`IMFVideoDisplayControl::SetBorderColor`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-setbordercolor)
160	/// method.
161	fn SetBorderColor(&self, color: COLORREF) -> HrResult<()> {
162		ok_to_hrresult(unsafe {
163			(vt::<IMFVideoDisplayControlVT>(self).SetBorderColor)(self.ptr(), color.into())
164		})
165	}
166
167	/// [`IMFVideoDisplayControl::SetFullscreen`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-setfullscreen)
168	/// method.
169	fn SetFullscreen(&self, full_screen: bool) -> HrResult<()> {
170		ok_to_hrresult(unsafe {
171			(vt::<IMFVideoDisplayControlVT>(self).SetFullscreen)(self.ptr(), full_screen as _)
172		})
173	}
174
175	/// [`IMFVideoDisplayControl::SetRenderingPrefs`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-setrenderingprefs)
176	/// method.
177	fn SetRenderingPrefs(&self, render_flags: co::MFVideoRenderPrefs) -> HrResult<()> {
178		ok_to_hrresult(unsafe {
179			(vt::<IMFVideoDisplayControlVT>(self).SetRenderingPrefs)(self.ptr(), render_flags.raw())
180		})
181	}
182
183	/// [`IMFVideoDisplayControl::SetVideoPosition`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-setvideoposition)
184	/// method.
185	///
186	/// At least one parameter must be passed.
187	fn SetVideoPosition(
188		&self,
189		src: Option<MFVideoNormalizedRect>,
190		dest: Option<RECT>,
191	) -> HrResult<()> {
192		ok_to_hrresult(unsafe {
193			(vt::<IMFVideoDisplayControlVT>(self).SetVideoPosition)(
194				self.ptr(),
195				pcvoid_or_null(src.as_ref()),
196				pcvoid_or_null(dest.as_ref()),
197			)
198		})
199	}
200
201	/// [`IMFVideoDisplayControl::SetVideoWindow`](https://learn.microsoft.com/en-us/windows/win32/api/evr/nf-evr-imfvideodisplaycontrol-setvideowindow)
202	/// method.
203	fn SetVideoWindow(&self, hwnd_video: &HWND) -> HrResult<()> {
204		ok_to_hrresult(unsafe {
205			(vt::<IMFVideoDisplayControlVT>(self).SetVideoWindow)(self.ptr(), hwnd_video.ptr())
206		})
207	}
208}